package com.sky.controller.user;

import com.sky.constant.StatusConstant;
import com.sky.pojo.Dish;
import com.sky.result.Result;
import com.sky.service.user.UserDishService;
import com.sky.vo.DishItemVO;
import com.sky.vo.DishVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@Api(tags = "用户端菜品相关接口")
@RequiredArgsConstructor
public class UserDishController {
    private final UserDishService userDishService;

    @ApiOperation("获取菜品列表")
    @GetMapping("/user/dish/list")
    public Result<List<DishVO>> list(@RequestParam Long categoryId) {
        log.info("获取菜品列表，分类id为{}", categoryId);
        Dish dish = new Dish();
        dish.setCategoryId(categoryId);
        dish.setStatus(StatusConstant.ENABLE);
        List<DishVO> list=userDishService.listWithFlavor(dish);
        /*List<DishVO> dishVOList=userDishService.list(categoryId);*/
        return Result.success(list);
    }
    @ApiOperation("根据id查询菜品")
    @GetMapping("/user/setmeal/dish/{setmealId}")
    public Result<List<DishItemVO>> getById(@PathVariable Long setmealId) {
        log.info("根据id查询菜品，id为{}", setmealId);
        List<DishItemVO> dishItemVOList=userDishService.getById(setmealId);
        return Result.success(dishItemVOList);
    }
}
